package GUI;

import java.util.Calendar;

import processing.core.PImage;

public class PlayPauseButton {
	PImage play;
	PImage pause;
	int x,y,width,height;
	boolean playT;
	boolean pressed;
	
	public PlayPauseButton(int x,int y,int width,int height){
		playT = false;
		this.x=x;
		this.y=y;
		this.width=width;
		this.height=height;
		play = GV.processing.loadImage("Play2.png");
		pause = GV.processing.loadImage("Pause2.png");
	}
	
	public void draw(){
		if(mouseOver()) 
		{
			if(GV.processing.mousePressed)
			{
				pressed = true;
			}
			else if(pressed)
			{
				pressed = false;
				if(playT){
					GV.lp.restoreStartEndIndices();
					GV.updateUfoToDisplay();
					playT=false;
				}
				else {playT=true;
				int val = (GV.dateStart.get(Calendar.YEAR)-2001)*12+GV.dateStart.get(Calendar.MONTH)+1;
				GV.dateEnd = GV.getDateFromMonthNumber(val);
				GV.dateEndIndex=val;
				}
			}
		}
		else
		{
			pressed = false;
		}
		if(playT) { GV.processing.image(pause, x, y,width,height); }
		else 	  {GV.processing.image(play, x, y,width,height); }
		
	}
	
	 public boolean mouseOver()
	  {
	    if(GV.processing.mouseX > x && GV.processing.mouseX < x + width && 
	    		GV.processing.mouseY > y && GV.processing.mouseY < y + height) 	return true;
	      return false;
	  }
	 
}
